package com.anmai.crawler1;

import com.anmai.crawler1.dao.ImgDao;
import com.anmai.crawler1.service.CrawlerService;
import com.anmai.crawler1.service.PhotoService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@SpringBootApplication
@MapperScan("com.anmai.crawler1.dao")
@EnableScheduling
public class Crawler1Application {

    public static void main(String[] args) {

        SpringApplication.run(Crawler1Application.class, args);

    }

    @Component
    class init implements CommandLineRunner{

        @Autowired
        private PhotoService photoService;

        @Override
        public void run(String... strings) throws Exception {
            System.out.println("请保证E盘有25G空间，如果没有请按ctrl+c退出。文件保存至E://imgs目录下");
            System.out.println("CJ is cool!");
            System.out.println("下载中(共25G)...");
            photoService.downloadImg();
            System.out.println("下载完成");
        }
    }

    /*@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // TODO Auto-generated method stub
        builder.sources(this.getClass());
        return super.configure(builder);
    }*/

}
